Skip to content

Conversation

@v-ein
Copy link
Collaborator

@v-ein v-ein commented Jan 5, 2026


name: Pull Request
about: Create a pull request to help us improve
title: Synced tables
assignees: ''


Description:
Technically Dear ImGui allows the caller to use the same item ID for two (or more) different item - I bet it started as a side effect but turned out to be useful in some cases. In particular, items with the same ID share whatever state is stored on ImGui side. In case of tables, this state includes column widths and probably some other data. That is, when two tables are assigned the same ID, they get somewhat "synced" and act as pieces of a single table. This can be useful e.g. when one wants to insert custom content between rows of a table - think of expanding rows or messages that occupy the entire table width. The feature is pretty stable, mentioned in a number of tickets and is even demonstrated in ImGui demo.

DearPyGui uses a ScopedID in mvTable::draw(), which makes every table ID unique in ImGui. This PR removes the ScopedID and allows two tables to have the same ID - for example, you can pass it in the label (which the table won't display anyway) as "###my-table-id". Remember to also set use_internal_label to False so that DPG uses the label and not UUID to create ImGui ID:

def create_table(num):
    with dpg.table(label="###table", use_internal_label=False, policy=dpg.mvTable_SizingFixedFit, resizable=True, hideable=True):
        dpg.add_table_column()
        dpg.add_table_column()
        with dpg.table_row():
            dpg.add_button(label="Lorem ipsum dolor sit")
            dpg.add_button(label="ipsum")

with dpg.window(pos=(10, 10), height=500, width=500):
    create_table(1)
    dpg.add_selectable(label="There's something between us")
    create_table(2)

synced-tables-1

The PR also adds a new container, synced_tables, which makes it easier to create synced table instances. All tables that are immediate children of a synced_tables item share their state without the need to explicitly assign them the same ID. The following code snippet behaves just like the one above - notice how dpg.table doesn't use that label trick:

def create_table(num):
    with dpg.table(policy=dpg.mvTable_SizingFixedFit, resizable=True, hideable=True):
        dpg.add_table_column()
        dpg.add_table_column()
        with dpg.table_row():
            dpg.add_button(label="Lorem ipsum dolor sit")
            dpg.add_button(label="ipsum")

with dpg.window(pos=(10, 10), height=500, width=500):
    with dpg.synced_tables():
        create_table(1)
        dpg.add_selectable(label="There's something between us")
        create_table(2)

Unfortunately there's no doc on this new feature, I hope to eventually add it... Maybe.

Concerning Areas:
None.

@v-ein v-ein requested a review from hoffstadt January 5, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant